package bai7.service;

import java.util.ArrayList;
import java.util.Scanner;

import bai7.model.Profile;
import bai7.service.implement.ProfileAPI;

public class ProfileDAO implements ProfileAPI{
	Scanner ip=new Scanner(System.in);
	ArrayList<Profile> list=new ArrayList<Profile>();

	public void nhapProfile() {
		System.out.println("Nhap so Profile can them");
		int n=Integer.parseInt(ip.nextLine());
		for(int i=1;i<=n;i++){
			System.out.println("Nhap thong tin Profile thu "+i);
			System.out.println("Nhap id: ");
			int id=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap name: ");
			String name=ip.nextLine();
			System.out.println("Nhap DateofBirth: ");
			String dateOfbirth=ip.nextLine();
			System.out.println("Nhap dia chi: ");
			String dc=ip.nextLine();
			System.out.println("Nhap email: ");
			String email=ip.nextLine();
			System.out.println("Nhap luong: ");
			int luong=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap so phone: ");
			int phone=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap chuc vu: ");
			String cv=ip.nextLine();
			Profile pf=new Profile(name,dc,dateOfbirth,email,id,luong,phone,cv);
			list.add(pf);}
	}
	public void inProfile() {
		System.out.println("=====================Danh sach Profile=======================\n");
		System.out.println("|id\t|Name\t\t\t|DateofBirth\t|Email\t\t\t|Luong\t\t|Phone\t\t|Chuc vu\n");
		for(Profile pf:list){
			System.out.println("|"+pf.getId()+"\t|"+pf.getName()+"\t\t\t|"+pf.getDateOfbirth()+"\t|"+pf.getEmail()+"\t|"+pf.getLuong()+"\t\t|"+pf.getPhone()+"\t\t|"+pf.getCv());
			System.out.println("-------------------------------------------------------------------------");
		}	
	}
	public void searchProfile(int id) {
		for(Profile pf:list){
			if(pf.getId()==id){
				System.out.println("|id\t|Name\t\t\t|DateofBirth\t|Email\t\t\t|Luong\t|Phone\t|Chuc vu\n");
				System.out.println("|"+pf.getId()+"\t|"+pf.getName()+"\t\t|"+pf.getDateOfbirth()+"\t|"+pf.getEmail()+"\t|"+pf.getLuong()+"\t"+pf.getPhone()+"\t"+pf.getCv());
			}
			else{
				System.out.println("Khong tim thay id ");
			}
		}	

	}
	public void deleteProfile(int id) {

		list.remove(id-1);

	}

}
